var t = require("../../../@babel/runtime/helpers/defineProperty"), a = require("../common.js"), e = getApp();

Page({
    behaviors: [ a ],
    data: {
        tabsIndex: 0,
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        listStatus: 1,
        store_info: {},
        codeShow: !1,
        codeList: {},
        codeUrl: "",
        is_boss: 0,
        status_arr: [ "未完成", "已完成", "申请取消", "取消成功", "", "", "", "", "", "取消失败" ]
    },
    onLoad: function(t) {
        t.status && this.setData({
            listStatus: t.status
        }), 1 == this.data.listStatus && (wx.setNavigationBarTitle({
            title: "我的预约"
        }), this.getStore()), this.getList();
    },
    initCustomField: function() {
        2 == this.data.listStatus && wx.setNavigationBarTitle({
            title: this.data.reserve_obj_text + "记录"
        });
    },
    setTabsIndex: function(t) {
        var a = t.currentTarget.dataset.index;
        this.setData({
            tabsIndex: a
        }), this.getList();
    },
    setCodeShow: function() {
        this.setData({
            codeShow: !this.data.codeShow
        });
    },
    gotoRefund: function(t) {
        var a = t.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageD/member/myOrder/refund/refund?order_id=" + a.order_id
        });
    },
    gotoAftersales: function(t) {
        var a = t.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageD/member/myOrder/Aftersales/Aftersales?refund_id=" + a.refund_id
        });
    },
    gotoGoods: function(t) {
        var a = t.currentTarget.dataset.item;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a.goods_id
        });
    },
    getCodeUrl: function(a) {
        var s = this, r = a.currentTarget.dataset.id;
        if (this.data.codeList[r]) this.setData({
            codeShow: !0,
            codeUrl: this.data.codeList[r]
        }); else {
            var i = e.getNetAddresss("plugin.reserve-simple.frontend.reserve-order.qr-code-url");
            e._getNetWork({
                url: i,
                data: {
                    id: r
                },
                success: function(a) {
                    var i = a.data;
                    if (1 != i.result) return e.tips(i.msg);
                    var o = "codeList[" + r + "]";
                    s.setData(t({
                        codeShow: !0,
                        codeUrl: i.data.qr_code_url
                    }, o, i.data.qr_code_url));
                }
            });
        }
    },
    onReady: function() {},
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            isLoadMore: !0,
            listData: [],
            networkLoading: !1
        });
    },
    getList: function() {
        var t = this;
        this.initData();
        var a = e.getNetAddresss("plugin.reserve-simple.frontend.reserve-order.get-my-list");
        2 == this.data.listStatus && (a = e.getNetAddresss("plugin.reserve-simple.frontend.reserve-order.get-all-list"));
        var s = {};
        0 != this.data.tabsIndex && (s.reserve_type = this.data.tabsIndex), e._getNetWork({
            url: a,
            data: s,
            success: function(a) {
                var s = a.data;
                if (1 != s.result) return e.tips(s.msg);
                console.log(s), t.data.total_page = s.data.last_page || s.data.list.last_page, t.data.total_page || (t.data.total_page = 0);
                var r = [], i = {};
                1 == t.data.listStatus ? r = s.data.data : 2 == t.data.listStatus && (r = s.data.list.data, 
                i.is_boss = s.data.is_boss), i.listData = r, i.networkLoading = !0, t.setData(i);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var a = {
                page: this.data.page
            }, s = e.getNetAddresss("plugin.reserve-simple.frontend.reserve-order.get-my-list");
            2 == this.data.listStatus && (s = e.getNetAddresss("plugin.reserve-simple.frontend.reserve-order.get-all-list")), 
            0 != this.data.tabsIndex && (a.reserve_type = this.data.tabsIndex), e._postNetWork({
                url: s,
                data: a,
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var s = [];
                        1 == t.data.listStatus ? s = t.data.listData.concat(e.data.data) : 2 == t.data.listStatus && (s = t.data.listData.concat(e.data.list.data)), 
                        t.setData({
                            listData: s
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    getStore: function() {
        var t = this, a = e.getNetAddresss("plugin.reserve-simple.frontend.index.get-shop-info");
        e._postNetWork({
            url: a,
            success: function(a) {
                var s = a.data;
                if (1 != s.result) return e.tips(s.msg);
                t.setData({
                    store_info: s.data
                });
            }
        });
    },
    goToAdress: function() {
        var t = this.data.store_info.lat, a = this.data.store_info.lng, s = this.data.store_info.name, r = e.BMapTransqqMap(parseFloat(a), parseFloat(t));
        wx.openLocation({
            latitude: r.lat,
            longitude: r.lng,
            scale: 18,
            name: s
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});